package cn.flying.cloud.file.api;

import java.io.IOException;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import cn.flying.cloud.file.model.FileRequest;

/**
 * 文件服务接口
 *
 * @author: admin
 * @date: 2024年05月27日 11:01
 * @version: 1.0
 */
public interface FileServiceApi {

    /**
     * 上传文件
     *
     * @param request
     * @return
     * @throws IOException
     */
    @PostMapping(value = "/upload")
    String upload(@RequestBody FileRequest request);

    /**
     * 下载文件
     *
     * @param bucket
     * @param filename
     */
    @GetMapping("/download")
    byte[] download(@RequestParam("bucket") String bucket, @RequestParam("filename") String filename);

    /**
     * 获取文件URL
     *
     * @param bucket
     * @param filename
     * @return
     */
    @GetMapping("/getObjectUrl/{bucket}/{filename}")
    String getObjectUrl(@PathVariable("bucket") String bucket, @PathVariable("filename") String filename);
}
